/**
 * Copyright (C), 2017, 用友政务
 * Author:      liwd
 * Date:        2018-06
 * Description: Redux store(开发环境)
 * History:
 */
import { applyMiddleware, createStore } from 'redux'
import thunk from 'redux-thunk'
import { composeWithDevTools } from 'redux-devtools-extension'
import { createLogger } from 'redux-logger'
import reducer from '../reducers/index'

//异步中间件
const middleware = [thunk]

//redux-logger打印日志中间件
const logger = createLogger({
  collapsed: true,
})
middleware.push(logger)

// 创建一个 Redux store 来以存放应用中所有的 state，应用中应有且仅有一个 store。
const store = createStore(
  reducer,
  // 使用redux-devtools-extension可视化工具帮助调试(浏览器需安装插件)。
  composeWithDevTools(applyMiddleware(...middleware)),
)

export default store
